
<?php 
	include_once("web_header.php");
?>
<script type="text/javascript"  src="/include/ajaxfileupload.js"></script>


 
<div class="web_wrap">
    <div class="reg_content_wrap">
         <div  style="width:25%;float:left;">
				<?php 
					include_once("web_coach_dashmenu.php");
				?>
         </div>
         <div class="dash_rightdiv">
 


     <div id="regform" >
		      <!-- step 1 -->

           <div class="subhead"> 
               <span class="glyphicon glyphicon-pencil"></span>  编辑基本信息
           </div>


		       <div id="step1" style=" position:relative; ">

 				      <div class="formgroup" style="height:100px">
					       <h3>上传头像</h3>
					               <div class="inputcontent">
					               <img src="<?=$coach->thumb?>" id="userthumb"> 
		                            <input id="userthumbfile" name="file" type="file" accept="image/*;capture=camera" onchange="upload('userthumbfile')" style="opacity:0; height:1px; width:1px; -webkit-appearance: none;  -moz-appearance: none; appearance: none; overflow: hidden;  " >
					               </div>
					    </div>

 			         <div class="formgroup">
			               <h3><span class="mustspan">*</span>姓名</h3>
						   <input  type="input" value="<?=$coach->fullname?>" name="fullname" id="fullname" placeholder="姓名">
		 	          </div>


			          <div class="formgroup">
			               <h3><span class="mustspan">*</span>性别</h3>
			               <div class="inputcontent">
			                    <span svar='1' class="sexselector buttondiv">帅哥</span> 
			                    <span svar='2' class="sexselector buttondiv">美女</span> 
 			               </div>
		 	          </div>
			          <div class="formgroup">
			               <h3><span class="mustspan">*</span>身高</h3>
						   <input type="input" value="<?=$coach->height?>" name="height" id="height" placeholder="厘米">
		 	          </div>
			          <div class="formgroup">
			               <h3>体重</h3>
						        <input type="input" value="<?=$coach->weight?>" name="weight" id="weight" placeholder="公斤">
		 	          </div>
			          <div class="formgroup">
			               <h3>出生年月</h3>
						        <input type="input" value="<?=$coach->birthday?>" name="birthday" id="birthday" placeholder="格式:1990-01-01">
			          </div>

 			          <div class="formgroup">
			               <h3>微信号或qq号</h3>
						         <input type="input" value="<?=$coach->qqnumber?>" name="qqnumber" id="qqnumber" placeholder="qq号码">
		 	          </div>


               <div class="formgroup" style="height:120px;">
                         <h3>自我介绍</h3>
                   <textarea name="selfintro" id="selfintro" placeholder="一两句话介绍你自己"><?=$coach->description?></textarea>
                    <div class="clearbox"></div>
                </div>


                <div class="formgroup" style="height:100px; ">
                     <h3><span class="mustspan">*</span>项目</h3>
                     <div class="inputcontent" id="stypeselectdiv">
                      <span svar="1" selectstatus="unselected" class="stypeselector buttondiv">健身</span> 
                          <span svar="2" selectstatus="unselected" class="stypeselector buttondiv">羽毛球</span> 
                          <span svar="3" selectstatus="unselected" class="stypeselector buttondiv">网球</span> 
 
                      <span svar="4" selectstatus="unselected" class="stypeselector buttondiv">高尔夫</span> 
                      <span svar="5" selectstatus="unselected" class="stypeselector buttondiv">游泳</span> 
                      <br>
                      <span svar="6" selectstatus="unselected" class="stypeselector buttondiv">瑜伽</span> 
 
                      <span svar="7" selectstatus="unselected" class="stypeselector buttondiv">跑步</span> 
                      <span svar="0" id="showorthertypebut"  selectstatus="unselected" class="stypeselector buttondiv">其他</span> 
                      <br>
                       </div>
                </div>

                 <div class="formgroup" id="othertypediv" style="display:none">
                     <h3> 其他项目</h3>
                     <input type="input" value="<?=$coach->orthertype?>" name="orthertype" id="orthertype" placeholder="如果以上没有列有">
                </div>



               <div class="formgroup" style="height:120px;">
                      <h3>执教经历</h3>
                      <textarea name="resume" id="resume" placeholder="执教经历"><?=$coach->resume?></textarea>
                      <div class="clearbox"></div>
               </div>

                <div class="formgroup" style="height:120px;">
                    <h3>所获奖项</h3>
                   <textarea name="sporttitle" id="sporttitle" placeholder="曾获得过的奖项"><?=$coach->sporttitle?></textarea>
                    <div class="clearbox"></div>
                </div>
                <div class="blankbox"></div>

		        </div>

        </div>

	      <div style="width:100%;  text-align:center; margin:auto; margin-top:20px;">
				  <button id="submitButton" type="" class="btn btn-primary">
				     <div id="submitButtonText">设置</div>
				  </button>
	      </div>

	 	  <div style="height:20px;">
	       </div>

  


         </div>
         <div style="clear:both"></div>

     </div>
</div>
 

<script type="text/javascript">

   var sexvar = '<?=$coach->sex?>';
   var userid = '';
   var phonenumber = '';
   var wx_openid = '';
   var stypevar = '<?=$coach->stype_main?>';
   var orthertypeval = '<?=$coach->orthertype?>';

   $(".sexselector").on('click',function(){
        var selectedvar = $(this).attr("svar");
        $(".sexselector").removeClass("buttondiv_selected");
        $(".sexselector").addClass("buttondiv");
        $(this).addClass("buttondiv_selected");
        $(this).removeClass("buttondiv");
        sexvar = selectedvar;
   });

   $(".sexselector").each(function(){
        var selectedvar = $(this).attr("svar");
        if(selectedvar == sexvar){
             $(this).addClass("buttondiv_selected");
        }

    });



   $(".stypeselector").on('click',function(){
        var selectedvar = $(this).attr("svar");
        $(".stypeselector").removeClass("buttondiv_selected");
        $(".stypeselector").addClass("buttondiv");
        $(this).addClass("buttondiv_selected");
        $(this).removeClass("buttondiv");
        stypevar = selectedvar;
        if(stypevar!=0){
             $("#othertypediv").hide();
             $("#othertype").val("");
        }
   });

      $("#showorthertypebut").on('click',function(){
        $("#othertypediv").show();
   });


   $(".stypeselector").each(function(){
        var selectedvar = $(this).attr("svar");
        if( selectedvar == stypevar){
             $(this).addClass("buttondiv_selected");
        }
    });

   if(orthertypeval!=''){
        $("#othertypediv").show();
   }

 
   $("#userthumb").on('click',function(){
          $("#userthumbfile").click();
   });


  function upload (fileupload_id) {

	  	layer.open({
		    content: '正在上传',
		    className: 'bluelayer'
		});

   
       $("#uploadbg").attr("src","images/uploadbg2.png"); 
      
        $.ajaxFileUpload({
             url         :'/api_fileupload.php',
             secureuri   :false,
             fileElementId  : fileupload_id ,
             dataType    : 'json',
             success: function (data, status)            //相当于java中try语句块的用法
             {
                 $("#userthumb").attr("src",data.filepath);
                 layer.open({
          				    content: '上传成功',
          				    time: 1
          				});

             },
             error: function (data, status, e)            //相当于java中catch语句块的用法
             {
                layer.open({
				    content: '出错了!可能是网络有点慢,请尝试从手机相册中选择照片上传',
				    tbtn: ['OK']
				});
                //$("#uploadbg").attr("src","images/uploadbg.png"); 
              }

         });
          return true;
   }
 
    var currentstep = 1;
    $("#submitButton").on('click',function(){
    	if(currentstep==1){
	         //$("#step1").fadeOut(300);
 	         sendInfo_1();
      	}
    	if(currentstep==2){
 	         sendInfo_2();
     	}
    	if(currentstep==3){
             sendInfo_3();
     	}
 
    });

    function showlayer(showword){
			layer.open({
			    content:showword,
			    style: 'background-color:#09C1FF; color:#fff; border:none;',
			    time: 2
			});
    }

    function sendInfo_1(){

 	    //获取所选取的
 	    var stype_arr = new Array();
  
 	    var fullname = $("#fullname").val();
 	    var phonenumber = $("#phonenumber").val();
 	    var qqnumber = $("#qqnumber").val();
 	    var sex = sexvar;
 	    var height = $("#height").val();
 	    var weight = $("#weight").val();
 	    var birthday = $("#birthday").val();
 	    var thumb = $("#userthumb").attr("src");
      var selfintro = $("#selfintro").val();
      var resume = $("#resume").val();
      var sporttitle = $("#sporttitle").val();
      var orthertype = $("#orthertype").val();


 	    layer.open({
  		    content: '正在提交',
  		    className: 'bluelayer'
  		});

        $.ajax({
            url: '/index.php/coach/web_dashboard_baseinfo_handle',
            type: 'POST',
            data:{ fullname:fullname,phonenumber:phonenumber,qqnumber:qqnumber,sex:sex,height:height,weight:weight,birthday:birthday,thumb:thumb,selfintro:selfintro,resume:resume,sporttitle:sporttitle,stype_main:stypevar,orthertype:orthertype},
            dataType: 'json',
            error: function(){
                  alert('Error loading PHP document'); 
                  posting = false;
                 },
            success: function(result){
 

			        if(result.result==7){
                      layer.open({
          						    content: '请重新登录',
           						    time: 2
      					      });
                      return;
                 }


                if(result.result==1){
                      layer.open({
						    content: '修改完成',
						    className: 'bluelayer',
						    time: 2
						});
                      return;
		 	         //send sms

                }else{
                      layer.open({
						    content: '请填写完整',
						    className: 'bluelayer',
						    time: 2
						});
                      return;

                }
                posting = false;
            }
        });

    }

  

</script>






<?php 
	include_once("web_footer.php");
?>
